import Vue from 'vue'
import Router from 'vue-router'

import app from '../views/app/app' // 公共部分
import banner from '../views/banner/banner'
import mhead from '../views/head/head'
import home from '../views/home/home'
import index from '../views/index/index'

Vue.use(Router)

var router = new Router({
  routes: [{
    path: '/app',
    component: app,
    children: [
      {
        path: 'home',
        name: 'home',
        components: {
          banner: banner,
          head: mhead,
          content: home
        },
        children: [
          {
            path: 'index',
            name: 'index',
            component: index,
            meta: {
              title: '首页',
              need_log: false
            }
          }
        ]
      }
    ]
  }]
})

// 修改网页标题
router.afterEach((to, from, next) => {
  document.title = to.matched[to.matched.length - 1].meta.title
})

// 抛出路由
export default router
